﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "考场签到单");
		
		examId = event.getArg("EXID");
		clsroomId = event.getArg("CRID");
	
		/* 加载考试任务 */
		sql = "SELECT 
					t_examtask.task_exid, 
					t_course.course_name, 
					t_course.course_code,
					t_course.course_credit, 
					t_institute.institute_name, 
					t_term.academic_year, 
					t_term.academic_term 
				FROM 
					t_examtask 
					INNER JOIN t_course ON t_course.cid = t_examtask.cid 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
					INNER JOIN t_term ON t_term.term_id = t_examtask.term_id 
				WHERE 
					t_examtask.task_exid = :taskExid ";
					
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="taskExid", value=examId, cfsqltype="cf_sql_char" );
		
		rs_examTask = queryObj.execute( sql=sql ).getResult();
		
		/*考场名称*/
		sql = "SELECT 
					classroom 
				FROM 
					t_classroom 
				WHERE 
					cr_id = :classroomId";

		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="classroomId", value=clsroomId, cfsqltype="cf_sql_char" );
		
		rs_classRoom = queryObj.execute( sql=sql ).getResult();
		
		/* 考场名单 */
		sql = "SELECT 
					t_student_exam.sitidx, 
					t_student.stu_id, 
					t_student.stu_name, 
					t_student.stu_sex 
				FROM 
					t_student_exam 
					INNER JOIN t_student ON t_student.stu_id = t_student_exam.stu_id 
				WHERE 
					t_student_exam.task_exid = :examId 
					AND 
					t_student_exam.cr_id = :clsroomId 
				ORDER BY 
					t_student_exam.sitidx ";
		
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char" );
		
		rs_student = queryObj.execute( sql=sql ).getResult();
	
		
		/* 默认显示行数及高度 */
		rowPerSlide = 40;
		rowPerPage = rowPerSlide * 2;
		
		if ( rs_student.recordCount ) {
			
			/* 计算打印页数 */
			if ( rs_student.recordCount mod rowPerPage ) {
				totlePageCount = int(rs_student.recordCount/rowPerPage) + 1;
			}
			else {
				totlePageCount = int(rs_student.recordCount/rowPerPage);
			}
			
			pageRowBegin = 1;
			pageRowEnd = min(rowPerPage, rs_student.recordCount);
			
			tagCode = "QDB-" & rs_examTask.task_exid;

		}
		
	</cfscript>
</cfsilent>

<cfloop from="1" to="#totlePageCount#" index="currentPage">
	
	<cfif currentPage GT 1><div class="page_break"></div></cfif>
	
	<div class="UIreportTitle">
		<h2><cfoutput>#rs_examTask.course_name#</cfoutput> <cfoutput>#rs_classRoom.classroom#</cfoutput> 考场签到表</h2>
	</div>
	
	<table width="98%" border="0" cellpadding="1" cellspacing="0">
		<tr>
			<td>课程号 <cfoutput>#rs_examTask.course_code#</cfoutput></td>
			<td>课程 <cfoutput>#rs_examTask.course_name#</cfoutput></td>
			<td>学分 <cfoutput>#numberFormat(rs_examTask.course_credit, "_.__")#</cfoutput></td>
			<td align="right">任课单位 <cfoutput>#rs_examTask.institute_name#</cfoutput></td>
		</tr>
		<tr>
			<td>学期 <cfoutput>#rs_examTask.academic_year#</cfoutput>-<cfoutput>#rs_examTask.academic_term#</cfoutput></td>
			<td>考场 <cfoutput>#rs_classRoom.classroom#</cfoutput></td>
			<td>考场人数 <cfoutput>#rs_student.recordCount#</cfoutput></td>
			<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td valign="top" width="50%">
				<!-- Silder Left -->
				<table class="UIprintable" width="100%" border="1" cellpadding="0" cellspacing="0">
					<tr>
						<td width="30">序</td>
						<td width="100">学号</td>
						<td width="80">姓名</td>
						<td width="30">性别</td>
						<td>签字</td>
					</tr>
					<cfset sliderRowBegin = pageRowBegin />
					<cfset sliderRowEnd = pageRowBegin + rowPerSlide -1 />
					<cfloop index="row" from="#sliderRowBegin#" to="#sliderRowEnd#">
						
						<cfif rs_student.recordCount gte row >
							<tr>
								<td><cfoutput>#rs_student["sitidx"][row]#</cfoutput></td>
								<td><cfoutput>#rs_student["stu_id"][row]#</cfoutput></td>
								<td align="left"><cfoutput>#rs_student["stu_name"][row]#</cfoutput></td>
								<td><cfif rs_student["stu_sex"][row] eq "1">男<cfelse>女</cfif></td>
								<td>&nbsp;</td>
							</tr>
							<cfelse>
							<tr>
								<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
							</tr>
						</cfif>
						
					</cfloop>
				</table>
			</td>
			<td width="5" valign="top">&nbsp;</td>
			<td valign="top" width="50%">
				<!-- Silder Right -->
				<table class="UIprintable" width="100%" border="1" cellpadding="0" cellspacing="0">
					<tr>
						<td width="30">序</td>
						<td width="100">学号</td>
						<td width="80">姓名</td>
						<td width="30">性别</td>
						<td>签字</td>
					</tr>
					<cfset sliderRowBegin = pageRowBegin + rowPerSlide />
					<cfset sliderRowEnd = pageRowBegin + 2*rowPerSlide -1 />
					<cfloop index="row" from="#sliderRowBegin#" to="#sliderRowEnd#">
						
						<cfif rs_student.recordCount gte row >
							<tr>
								<td><cfoutput>#rs_student["sitidx"][row]#</cfoutput></td>
								<td><cfoutput>#rs_student["stu_id"][row]#</cfoutput></td>
								<td align="left"><cfoutput>#rs_student["stu_name"][row]#</cfoutput></td>
								<td><cfif rs_student["stu_sex"][row] eq "1">男<cfelse>女</cfif></td>
								<td>&nbsp;</td>
							</tr>
							<cfelse>
							<tr>
								<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
							</tr>
						</cfif>
						
					</cfloop>
				</table>
			</td>
		</tr>
	</table>
	
	<div class="UIreportFoot">
		<table>
			<tr>
                <td width="150">打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
                <td width="180">监考教师签名</td>
                <td width="100">第 <cfoutput>#currentPage#</cfoutput> 页, 共 <cfoutput>#totlePageCount#</cfoutput> 页</td>
                <td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>,<cfoutput>#currentPage#</cfoutput>.png" height="43"/></td>
            </tr>
		</table>
	</div>
	
	<cfset pageRowBegin = pageRowBegin + rowPerPage />
	<cfset pageRowEnd = pageRowEnd + rowPerPage />
	<cfif pageRowEnd gt rs_student.recordCount>
		<cfset pageRowEnd = rs_student.recordCount />
	</cfif>
	
</cfloop>